import request from '@/axios'
import {SysMessageDetailVo, SysMessageEditQo, SysMessageListVo, SysMessageNotReadCountVo, SysMessageSearchQo} from './types'
import { BaseDeleteQo } from '@/base/api/BaseQo'
import { KeyLabelValueVo } from '@/base/api/KeyLabelValueVo'

export const sysMessagePageApi = (data: SysMessageSearchQo): Promise<IResponse<Array<SysMessageListVo>>> => {
  return request.post({ url: '/sysMessage/page.adw', data })
}

export const sysMessageMyPageApi = (data: SysMessageSearchQo): Promise<IResponse<Array<SysMessageListVo>>> => {
  return request.post({ url: '/sysMessage/myPage.adw', data })
}

export const sysMessageDetailApi = (id: number): Promise<IResponse<SysMessageDetailVo>> => {
  const data = { id }
  return request.post({
    url: '/sysMessage/detail.adw',
    data
  })
}

export const sysMessageAddApi = (data: SysMessageEditQo): Promise<IResponse<number>> => {
  return request.post({ url: '/sysMessage/add.adw', data })
}

export const sysMessageUpdateApi = (data: SysMessageEditQo): Promise<IResponse<void>> => {
  return request.post({ url: '/sysMessage/update.adw', data })
}

export const sysMessageDeleteApi = (data: BaseDeleteQo): Promise<IResponse<void>> => {
  return request.post({ url: '/sysMessage/delete.adw', data })
}

export const sysMessageAllReadApi = (data: SysMessageEditQo): Promise<IResponse<number>> => {
  return request.post({ url: '/sysMessage/myAllRead.adw', data })
}

export const sysMessageMarkReadApi = (data: SysMessageEditQo): Promise<IResponse<number>> => {
  return request.post({ url: '/sysMessage/markRead.adw', data })
}

export const sysMessageNotReadCountApi = (): Promise<IResponse<SysMessageNotReadCountVo>> => {
  return request.post({ url: '/sysMessage/notReadCount.adw' })
}

// [[ OnflowGenerator Range (- selectFunctions -) Start ]]
export const selectSysMessageTitleListApi = (
  data: SysMessageSearchQo
): Promise<IResponse<Array<KeyLabelValueVo>>> => {
  return request.post({ url: '/sysMessage/selectTitleList.adw', data })
}
// [[ OnflowGenerator Range (- selectFunctions -) End ]]
